1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module adw.ActionRow;
26 
27 private import adw.PreferencesRow;
28 private import adw.c.functions;
29 public  import adw.c.types;
30 private import glib.ConstructionException;
31 private import glib.Str;
32 private import glib.c.functions;
33 private import gobject.ObjectG;
34 private import gobject.Signals;
35 private import gtk.Widget;
36 private import std.algorithm;
37 
38 
39 /**
40  * A [class@Gtk.ListBoxRow] used to present actions.
41  * 
42  * <picture>
43  * <source srcset="action-row-dark.png" media="(prefers-color-scheme: dark)">
44  * <img src="action-row.png" alt="action-row">
45  * </picture>
46  * 
47  * The `AdwActionRow` widget can have a title, a subtitle and an icon. The row
48  * can receive additional widgets at its end, or prefix widgets at its start.
49  * 
50  * It is convenient to present a preference and its related actions.
51  * 
52  * `AdwActionRow` is unactivatable by default, giving it an activatable widget
53  * will automatically make it activatable, but unsetting it won't change the
54  * row's activatability.
55  * 
56  * ## AdwActionRow as GtkBuildable
57  * 
58  * The `AdwActionRow` implementation of the [iface@Gtk.Buildable] interface
59  * supports adding a child at its end by specifying “suffix” or omitting the
60  * “type” attribute of a <child> element.
61  * 
62  * It also supports adding a child as a prefix widget by specifying “prefix” as
63  * the “type” attribute of a <child> element.
64  * 
65  * ## CSS nodes
66  * 
67  * `AdwActionRow` has a main CSS node with name `row`.
68  * 
69  * It contains the subnode `box.header` for its main horizontal box, and
70  * `box.title` for the vertical box containing the title and subtitle labels.
71  * 
72  * It contains subnodes `label.title` and `label.subtitle` representing
73  * respectively the title label and subtitle label.
74  *
75  * Since: 1.0
76  */
77 public class ActionRow : PreferencesRow
78 {
79 	/** the main Gtk struct */
80 	protected AdwActionRow* adwActionRow;
81 
82 	/** Get the main Gtk struct */
83 	public AdwActionRow* getActionRowStruct(bool transferOwnership = false)
84 	{
85 		if (transferOwnership)
86 			ownedRef = false;
87 		return adwActionRow;
88 	}
89 
90 	/** the main Gtk struct as a void* */
91 	protected override void* getStruct()
92 	{
93 		return cast(void*)adwActionRow;
94 	}
95 
96 	/**
97 	 * Sets our main struct and passes it to the parent class.
98 	 */
99 	public this (AdwActionRow* adwActionRow, bool ownedRef = false)
100 	{
101 		this.adwActionRow = adwActionRow;
102 		super(cast(AdwPreferencesRow*)adwActionRow, ownedRef);
103 	}
104 
105 	/**
106 	 * Activates @self.
107 	 *
108 	 * Since: 1.0
109 	 */
110 	public override bool activate()
111 	{
112 		adw_action_row_activate(adwActionRow);
113 		return true;
114 	}
115 
116 	/**
117 	 */
118 
119 	/** */
120 	public static GType getType()
121 	{
122 		return adw_action_row_get_type();
123 	}
124 
125 	/**
126 	 * Creates a new `AdwActionRow`.
127 	 *
128 	 * Returns: the newly created `AdwActionRow`
129 	 *
130 	 * Since: 1.0
131 	 *
132 	 * Throws: ConstructionException GTK+ fails to create the object.
133 	 */
134 	public this()
135 	{
136 		auto __p = adw_action_row_new();
137 
138 		if(__p is null)
139 		{
140 			throw new ConstructionException("null returned by new");
141 		}
142 
143 		this(cast(AdwActionRow*) __p);
144 	}
145 
146 	/**
147 	 * Adds a prefix widget to @self.
148 	 *
149 	 * Params:
150 	 *     widget = a widget
151 	 *
152 	 * Since: 1.0
153 	 */
154 	public void addPrefix(Widget widget)
155 	{
156 		adw_action_row_add_prefix(adwActionRow, (widget is null) ? null : widget.getWidgetStruct());
157 	}
158 
159 	/**
160 	 * Adds a suffix widget to @self.
161 	 *
162 	 * Params:
163 	 *     widget = a widget
164 	 *
165 	 * Since: 1.0
166 	 */
167 	public void addSuffix(Widget widget)
168 	{
169 		adw_action_row_add_suffix(adwActionRow, (widget is null) ? null : widget.getWidgetStruct());
170 	}
171 
172 	/**
173 	 * Gets the widget activated when @self is activated.
174 	 *
175 	 * Returns: the activatable widget for @self
176 	 *
177 	 * Since: 1.0
178 	 */
179 	public Widget getActivatableWidget()
180 	{
181 		auto __p = adw_action_row_get_activatable_widget(adwActionRow);
182 
183 		if(__p is null)
184 		{
185 			return null;
186 		}
187 
188 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p);
189 	}
190 
191 	/**
192 	 * Gets the icon name for @self.
193 	 *
194 	 * Returns: the icon name for @self
195 	 *
196 	 * Since: 1.0
197 	 */
198 	public string getIconName()
199 	{
200 		return Str.toString(adw_action_row_get_icon_name(adwActionRow));
201 	}
202 
203 	/**
204 	 * Gets the subtitle for @self.
205 	 *
206 	 * Returns: the subtitle for @self
207 	 *
208 	 * Since: 1.0
209 	 */
210 	public string getSubtitle()
211 	{
212 		return Str.toString(adw_action_row_get_subtitle(adwActionRow));
213 	}
214 
215 	/**
216 	 * Gets the number of lines at the end of which the subtitle label will be
217 	 * ellipsized.
218 	 *
219 	 * If the value is 0, the number of lines won't be limited.
220 	 *
221 	 * Returns: the number of lines at the end of which the subtitle label will be
222 	 *     ellipsized
223 	 *
224 	 * Since: 1.0
225 	 */
226 	public int getSubtitleLines()
227 	{
228 		return adw_action_row_get_subtitle_lines(adwActionRow);
229 	}
230 
231 	/**
232 	 * Gets the number of lines at the end of which the title label will be
233 	 * ellipsized.
234 	 *
235 	 * If the value is 0, the number of lines won't be limited.
236 	 *
237 	 * Returns: the number of lines at the end of which the title label will be
238 	 *     ellipsized
239 	 *
240 	 * Since: 1.0
241 	 */
242 	public int getTitleLines()
243 	{
244 		return adw_action_row_get_title_lines(adwActionRow);
245 	}
246 
247 	/**
248 	 * Removes a child from @self.
249 	 *
250 	 * Params:
251 	 *     widget = the child to be removed
252 	 *
253 	 * Since: 1.0
254 	 */
255 	public void remove(Widget widget)
256 	{
257 		adw_action_row_remove(adwActionRow, (widget is null) ? null : widget.getWidgetStruct());
258 	}
259 
260 	/**
261 	 * Sets the widget to activate when @self is activated.
262 	 *
263 	 * Params:
264 	 *     widget = the target widget
265 	 *
266 	 * Since: 1.0
267 	 */
268 	public void setActivatableWidget(Widget widget)
269 	{
270 		adw_action_row_set_activatable_widget(adwActionRow, (widget is null) ? null : widget.getWidgetStruct());
271 	}
272 
273 	/**
274 	 * Sets the icon name for @self.
275 	 *
276 	 * Params:
277 	 *     iconName = the icon name
278 	 *
279 	 * Since: 1.0
280 	 */
281 	public void setIconName(string iconName)
282 	{
283 		adw_action_row_set_icon_name(adwActionRow, Str.toStringz(iconName));
284 	}
285 
286 	/**
287 	 * Sets the subtitle for @self.
288 	 *
289 	 * Params:
290 	 *     subtitle = the subtitle
291 	 *
292 	 * Since: 1.0
293 	 */
294 	public void setSubtitle(string subtitle)
295 	{
296 		adw_action_row_set_subtitle(adwActionRow, Str.toStringz(subtitle));
297 	}
298 
299 	/**
300 	 * Sets the number of lines at the end of which the subtitle label will be
301 	 * ellipsized.
302 	 *
303 	 * If the value is 0, the number of lines won't be limited.
304 	 *
305 	 * Params:
306 	 *     subtitleLines = the number of lines at the end of which the subtitle label will be ellipsized
307 	 *
308 	 * Since: 1.0
309 	 */
310 	public void setSubtitleLines(int subtitleLines)
311 	{
312 		adw_action_row_set_subtitle_lines(adwActionRow, subtitleLines);
313 	}
314 
315 	/**
316 	 * Sets the number of lines at the end of which the title label will be
317 	 * ellipsized.
318 	 *
319 	 * If the value is 0, the number of lines won't be limited.
320 	 *
321 	 * Params:
322 	 *     titleLines = the number of lines at the end of which the title label will be ellipsized
323 	 *
324 	 * Since: 1.0
325 	 */
326 	public void setTitleLines(int titleLines)
327 	{
328 		adw_action_row_set_title_lines(adwActionRow, titleLines);
329 	}
330 
331 	/**
332 	 * This signal is emitted after the row has been activated.
333 	 *
334 	 * Since: 1.0
335 	 */
336 	gulong addOnActivated(void delegate(ActionRow) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
337 	{
338 		return Signals.connect(this, "activated", dlg, connectFlags ^ ConnectFlags.SWAPPED);
339 	}
340 }